﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SPSIndia.XSLDemo.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SPSIndia.XSLDemo/VisualWebPart1/VisualWebPart1UserControl.ascx";

        private string myXslUrl;

        // Added to HelloVisualWebPart.cs 
        [WebBrowsable(true)]
        [WebDisplayName("XSL File URL")]
        [WebDescription("This XSL file controls the formatting of the web part's output.")]
        [Personalizable(PersonalizationScope.User)]
        [Category("SPSIndia")]
        public string XslUrl
        {
            get
            {
                return myXslUrl;
            }
            set
            {
                myXslUrl = value;
            }
        }

        private bool doEncodeHtmlResults = true;
        [WebBrowsable(true)]
        [WebDisplayName("Encode Transform Results?")]
        [WebDescription("If true, the transformed results are HTML Encoded.  Useful for debugging.")]
        [Personalizable(PersonalizationScope.User)]
        [Category("SPSIndia")]
        public bool DoEncodeHtmlResults
        {
            get
            {
                return doEncodeHtmlResults;
            }
            set
            {
                doEncodeHtmlResults = value;
            }
        }



        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);

            ((VisualWebPart1UserControl)control).myParent = this;

            Controls.Add(control);

        }
    }
}
